package wordcountdemo

import org.apache.flink.api.scala._

/***
  * 批处理WorldCount
  *
  */
object WorldCount {
  def main(args: Array[String]): Unit = {
    val executionWorldCount = ExecutionEnvironment.getExecutionEnvironment
    val wordsFile: DataSet[String] = executionWorldCount.readTextFile("D:\\IdeaProjects\\FlinkStudyScala\\src\\main\\resources\\words.txt")

    val wordsCount: AggregateDataSet[(String, Int)] = wordsFile.flatMap(s => {
      s.split(" ")
    }).map((_,1)).groupBy(0).sum(1)
    wordsCount.print()
  }

}
